<template>
	<view class="content">
		<!-- 搜索组件 -->
		<view class="search-box" @click="gotoSearch">
			<u-search placeholder="搜索" input-align="center" :show-action="false" height="70"></u-search>
		</view>

		<!-- 轮播图区域 -->
		<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000" :circular="true">
			<swiper-item v-for="(item,i) in swiperList" :key="i">
				<navigator class="swiper-item" :url="'searchto/shop_detail/shop_detail'">
					<image :src="item.image_src" @click="chamge"></image>
				</navigator>
			</swiper-item>
		</swiper>
		<!-- 分类导航区域 -->
		<view class="nav-list">
			<view class="nav-item" v-for="(item,index) in navList" :key='index' @click="navClickHandler(item)">
				<image :src="item.image_src" class="nav-img"></image>
			</view>
		</view>
		<!-- 楼层区域 -->
		<view class="floor-list">
			<!-- 楼层 item 项 -->
			<view class="floor-item" v-for="(item, index) in floorList" :key="index">
				<view>
					<!-- 楼层标题 -->
					<image :src="item.floor_title.image_src" class="floor-title"></image>
				</view>
				<view class="floor-img-box">
					<view class="left-img-box">
						<image :src="item.product_list[0].image_src"
							:style="{width: item.product_list[0].image_width + 'rpx'}" mode="widthFix"
							@click="click_item( item.product_list[0])"></image>
					</view>
					<view class="right-img-box">
						<view class="right-img-item" v-for="(item2, i2) in item.product_list" :key="i2" v-if="i2 !== 0">
							<image :src="item2.image_src" mode="widthFix" :style="{width: item2.image_width + 'rpx'}">
							</image>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		swiperList,
		navList,
		floorList
	} from "@/utils/baseData.js"
	export default {
		data() {
			return {
				// 轮播图数据列表floorList
				swiperList: swiperList,
				//分类导航数据列表
				navList: navList,
				//楼层图片数据列表
				floorList: floorList
			}
		},
		onLoad() {
			console.log(floorList)

		},
		methods: {
			navClickHandler(item) {
				uni.switchTab({
					url: "../cate/cate"
				})
			},
			click_item(item) {
				console.log(item);
				uni.switchTab({
					url: item.navigator_url
				})
			},
			chamge(){
				uni.navigateTo({
					url:'../../searchto/goods_detail/goods_detail'
				})
			},

			gotoSearch() {
				uni.navigateTo({
					url: '../../searchto/search/search'
				})
			}
		}
	}
</script>

<style lang="scss">
	.swiper {
		height: 330rpx;

		.swiper-item {
			image {
			 width: 100%;
			 height: 100%;
			}
		}

	}

	.nav-list {
		display: flex;
		justify-content: space-around;
		margin: 15px 0;

		.nav-img {
			width: 128rpx;
			height: 140rpx;
		}
	}

	.floor-title {
		height: 60rpx;
		width: 100%;
		display: flex;
	}

	.right-img-box {
		display: flex;
		flex-wrap: wrap;
		justify-content: space-around;
	}

	.left-img-box {
		// width: 100rpx;
		// height: 128rpx;
	}

	.floor-img-box {
		display: flex;
		padding-left: 10rpx;
	}

	.search-box {
		position: sticky;
		background-color: #C00000;
		padding: 15rpx 32rpx;
		// top: 100rpx;
		top: 0;
		z-index: 2;
	}
</style>
